﻿var http=require("http");
var url=require("url");
var querystring=require("querystring");

function start(route){
	
	function onRequest(request,response){
		var pathname=url.parse(request.url).pathname;
		console.log("Request for "+pathname+" received.");
		var args=url.parse(request.url).query;  //获取参数，格式：args=1&args=2&args=3格式。
		console.log(querystring.parse(args).name);  //获取姓名参数
		console.log(querystring.parse(args).psw);   //获取密码参数
		
		route(pathname);
		
		response.writeHead(200,{"Content-Type":"text/plain"});
		response.write("Hello World!");
		response.end();
	}
	
	http.createServer(onRequest).listen(8888);
	console.log("Server has started.");
	
}

exports.start=start;